# 字符串
# 90%的代码都是在做字符串处理

# str_a = "hello~world"
# print(dir(str_a))

"""['__add__', '__class__', '__contains__', '__delattr__', 
'__dir__', '__doc__', '__eq__', '__format__', '__ge__', 
'__getattribute__', '__getitem__', '__getnewargs__', 
'__gt__', '__hash__', '__init__', '__init_subclass__', 
'__iter__', '__le__', '__len__', '__lt__', '__mod__', 
'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
 '__repr__', '__rmod__', '__rmul__', '__setattr__', 
 '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 
 'casefold', 'center', 'count', 'encode', 'endswith', 
 'expandtabs', 'find', 'format', 'format_map', 'index', 
 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 
 'isidentifier', 'islower', 'isnumeric', 'isprintable', 
 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 
 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 
 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 
 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 
 'translate', 'upper', 'zfill']
"""
"""
str_upper = "ABCDEF"
print(f"{str_upper} to_lower {str_upper.lower()}") #转成小写

str_split = "1,2,3,4,5,6,7"
print(f"{str_split} to_split {str_split.split(',')}") #分割

str_conent = "你好我是 浩恩，今年18岁"
print(f"{str_conent} 是否包含 浩恩 {str_conent.__contains__('浩恩')}") #是否包含
"""
# 转义学习
"""
print("hello\nworld")
print("hello\tworld")
print("hello\bworld")
print("hello\\nworld")
"""
# 格式化输出
"""
var_name = "吴彦祖"
var_age = 18
var_weight = 200

print("大家好我的名字叫：" + var_name + " 今年" + str(var_age) +"岁 体重是" + str(var_weight)+"斤！！")

var_format = "大家好我的名字是{}，今年{}岁，体重是{}斤".format(var_name,var_age,var_weight)
print(var_format)
print(f"大家好我的名字是{var_name}，今年{var_age}岁，体重是{var_weight}斤！")
"""
# 查找字符串的位置
"""
find_str = "Hello 124456 world"
print(find_str.find('H'))
print(find_str.find('124456'))
print(find_str.find('world'))
print(find_str.find('rld'))
"""

#字符串替换
replace_str = "你好，你是我的{role}助手，现在需要你讲一个关于{object}的笑话"
print(replace_str.replace("{role}","笑话").replace("{object}","偶是开发"))
print(replace_str.replace("{role}","翻译").replace("{object}","美国人"))

